package snapex.expense.mapper;

import static org.mybatis.dynamic.sql.SqlBuilder.*;
import static snapex.expense.mapper.ProjectCustomerInfoDynamicSqlSupport.*;

import java.util.List;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.SqlBuilder;
import org.mybatis.dynamic.sql.delete.DeleteDSL;
import org.mybatis.dynamic.sql.delete.MyBatis3DeleteModelAdapter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.render.RenderingStrategy;
import org.mybatis.dynamic.sql.select.MyBatis3SelectModelAdapter;
import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
import org.mybatis.dynamic.sql.select.SelectDSL;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.MyBatis3UpdateModelAdapter;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import snapex.core.model.ProjectCustomerInfo;

@Mapper
public interface HtcProjectCustomerInfoMapper {
    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<ProjectCustomerInfo> insertStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("ProjectCustomerInfoResult")
    ProjectCustomerInfo selectOne(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="ProjectCustomerInfoResult", value = {
        @Result(column="pc_gmis_project_id", property="pcGmisProjectId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="pc_customer_name", property="pcCustomerName", jdbcType=JdbcType.VARCHAR),
        @Result(column="pc_cost_center_mandatory", property="pcCostCenterMandatory", jdbcType=JdbcType.VARCHAR)
    })
    List<ProjectCustomerInfo> selectMany(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<Long>> countByExample() {
        return SelectDSL.selectWithMapper(this::count, SqlBuilder.count())
                .from(projectCustomerInfo);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default DeleteDSL<MyBatis3DeleteModelAdapter<Integer>> deleteByExample() {
        return DeleteDSL.deleteFromWithMapper(this::delete, projectCustomerInfo);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int deleteByPrimaryKey(String pcGmisProjectId_) {
        return DeleteDSL.deleteFromWithMapper(this::delete, projectCustomerInfo)
                .where(pcGmisProjectId, isEqualTo(pcGmisProjectId_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insert(ProjectCustomerInfo record) {
        return insert(SqlBuilder.insert(record)
                .into(projectCustomerInfo)
                .map(pcGmisProjectId).toProperty("pcGmisProjectId")
                .map(pcCustomerName).toProperty("pcCustomerName")
                .map(pcCostCenterMandatory).toProperty("pcCostCenterMandatory")
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertSelective(ProjectCustomerInfo record) {
        return insert(SqlBuilder.insert(record)
                .into(projectCustomerInfo)
                .map(pcGmisProjectId).toPropertyWhenPresent("pcGmisProjectId", record::getPcGmisProjectId)
                .map(pcCustomerName).toPropertyWhenPresent("pcCustomerName", record::getPcCustomerName)
                .map(pcCostCenterMandatory).toPropertyWhenPresent("pcCostCenterMandatory", record::getPcCostCenterMandatory)
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<ProjectCustomerInfo>>> selectByExample() {
        return SelectDSL.selectWithMapper(this::selectMany, pcGmisProjectId, pcCustomerName, pcCostCenterMandatory)
                .from(projectCustomerInfo);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<ProjectCustomerInfo>>> selectDistinctByExample() {
        return SelectDSL.selectDistinctWithMapper(this::selectMany, pcGmisProjectId, pcCustomerName, pcCostCenterMandatory)
                .from(projectCustomerInfo);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default ProjectCustomerInfo selectByPrimaryKey(String pcGmisProjectId_) {
        return SelectDSL.selectWithMapper(this::selectOne, pcGmisProjectId, pcCustomerName, pcCostCenterMandatory)
                .from(projectCustomerInfo)
                .where(pcGmisProjectId, isEqualTo(pcGmisProjectId_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExample(ProjectCustomerInfo record) {
        return UpdateDSL.updateWithMapper(this::update, projectCustomerInfo)
                .set(pcGmisProjectId).equalTo(record::getPcGmisProjectId)
                .set(pcCustomerName).equalTo(record::getPcCustomerName)
                .set(pcCostCenterMandatory).equalTo(record::getPcCostCenterMandatory);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExampleSelective(ProjectCustomerInfo record) {
        return UpdateDSL.updateWithMapper(this::update, projectCustomerInfo)
                .set(pcGmisProjectId).equalToWhenPresent(record::getPcGmisProjectId)
                .set(pcCustomerName).equalToWhenPresent(record::getPcCustomerName)
                .set(pcCostCenterMandatory).equalToWhenPresent(record::getPcCostCenterMandatory);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKey(ProjectCustomerInfo record) {
        return UpdateDSL.updateWithMapper(this::update, projectCustomerInfo)
                .set(pcCustomerName).equalTo(record::getPcCustomerName)
                .set(pcCostCenterMandatory).equalTo(record::getPcCostCenterMandatory)
                .where(pcGmisProjectId, isEqualTo(record::getPcGmisProjectId))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKeySelective(ProjectCustomerInfo record) {
        return UpdateDSL.updateWithMapper(this::update, projectCustomerInfo)
                .set(pcCustomerName).equalToWhenPresent(record::getPcCustomerName)
                .set(pcCostCenterMandatory).equalToWhenPresent(record::getPcCostCenterMandatory)
                .where(pcGmisProjectId, isEqualTo(record::getPcGmisProjectId))
                .build()
                .execute();
    }
}